package com.lscdu.gulimall.ruoyi_springboot.controller;

import com.lscdu.gulimall.ruoyi_springboot.bean.login.LoginBody;
import com.lscdu.gulimall.ruoyi_springboot.service.SysLoginService;
import com.lscdu.gulimall.ruoyi_springboot.utis.AjaxResult;
import com.lscdu.gulimall.ruoyi_springboot.utis.constant.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 啊昌
 * @date 2024/9/9 11:28
 * SysLoginController 登录验证
 */

@RestController
public class SysLoginController {

	@Autowired
	private SysLoginService sysLoginService;
	/**
	 * 登录方法
	 *
	 * @param loginBody 登录信息
	 * @return 结果
	 */
	@PostMapping("/login")
	public AjaxResult login(@RequestBody LoginBody loginBody) {
		AjaxResult ajax = AjaxResult.success();
		// 生成token 令牌
		String token = sysLoginService.login(loginBody);
		ajax.put(Constants.TOKEN, token);
		return ajax;
	}
}
